﻿using OrBitDataModule.CustomEventHandler;
using OrBitDataModule.Interface;
using OrBitDataModule.Models;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace OrBitDataModule.Base
{
    public abstract class ScriptBase
    {
        private void Init(IContext context)
        {
            Context = context;
        }
        /// <summary>
        /// 基础上下文
        /// </summary>
        public IContext Context { get; private set; }
        /// <summary>
        /// 脚本加载事件
        /// </summary>
        public abstract void OnLoad();
        /// <summary>
        /// 任务启动后事件
        /// </summary>
        public abstract void OnStarted();
        /// <summary>
        /// 任务停止后事件
        /// </summary>
        public abstract void OnStoped();
        /// <summary>
        /// 脚本卸载事件
        /// </summary>
        public abstract void OnDispose();
        /// <summary>
        /// 发送错误
        /// </summary>
        public abstract void OnError(Exception exception);
        /// <summary>
        /// 文件触发事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public abstract void OnFileSystem_Changed(object sender, ProcessedFileSystemEventArgs e);
        /// <summary>
        /// Socket数据接收事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public abstract void SocketClient_OnDataReceived(object sender, ReceivedDataEventArgs e);
        /// <summary>
        /// 串口数据接收事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public abstract void SerialPort_DataReceived(object sender, SerialPortReceivedEventArgs e);
        /// <summary>
        /// 在Http服务请求事件
        /// </summary>
        /// <param name="request"></param>
        /// <param name="response"></param>
        public abstract void OnHttpRequest(HttpListenerRequest request, HttpListenerResponse response);
        /// <summary>
        /// 接口提交前事件
        /// </summary>
        /// <param name="inputParameter">提交参数</param>
        /// <param name="inputRequest">提交内容</param>
        public abstract void BeforeSubmit(InputParameter inputParameter, string inputRequest);
        /// <summary>
        /// 接口文件内容提交后事件
        /// </summary>
        /// <param name="result">提交结果</param>
        /// <param name="returnMessage">返回信息</param>
        /// <param name="outputResponse">响应信息</param>
        public abstract void AfterSubmit(bool result, string returnMessage, string outputResponse);
    }
}
